Repository navigation
Validate e2e consensus traces against the Lean model in CI - #8732
Conversation
74c28e9 to
973e0e8
Compare
6d42d75 to
68ef415
Compare
68ef415 to
2578f17
Compare
2578f17 to
0779d6c
Compare
Replay takes one NDJSON file of {process_id, h_ts, msg} records from all
nodes in any order. It orders each process's records by h_ts, splits them
into per-node streams, and reduces each stream into groups by grammar
alone. A scheduler repeatedly runs, atomically, the next group of any node
whose group is enabled, preferring the earliest h_ts. Receives wait for a
matching queued packet and init_as_backup for a committed source; replay
fails if groups remain but none is enabled, listing the waiting groups.
Fixtures gain process_id and h_ts. The interleaved control records the
joiner's events among the leader's, including a same-name event inside
the leader's group, receives before their sends, and initialization
before the leader commits.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
check-order.py replays each trace after shuffling its records, and after also moving each node into its own process with a random, gapped h_ts counter, which changes the order in which enabled groups run. CI runs it on the fixtures and on the cft_scenario_test captures. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Each node's events are still reduced in h_ts order, which is the order of its lock holds. Replay now treats h_ts as the order of execution within a process, prefers the earliest wall-clock time among processes, and waits only for a group that is not enabled, so clock skew cannot fail a trace. Snapshot hooks, which run outside the lock, no longer absorb the groups that fall before the initialization, and bootstrap accepts a nomination before genesis. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Reduction.lean now only defines the rules, each consuming one lock hold of a node. Groups.lean peeks a node's next event, runs one rule from it and takes what the rule emitted as a group, so the rules track neither the group's node nor where it starts and ends. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A snapshot hook is valid if its node initializes later, which the hook rule can read from the node's remaining events, so the rules no longer track whether the node is initialized or a hook is pending. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The snapshot hooks stay in the init_as_backup rule, which now stops after them when the initialization does not directly follow and requires it later in the node's events. The rules otherwise differ from main only in accepting a nomination before genesis. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A group that waits is retried after every other group that runs. Its reason rendered and sorted the whole pending queue between its sender and receiver each time, and was discarded whenever another group could run. The waiting check now returns the reason as a thunk, forced only by the stuck report. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Snapshot hooks run outside the consensus lock, so they are not part of the initialization's lock hold even when it directly follows them in the node's events. Grouping them made the group start at the hook, and another node's group between hook and initialization in the same process was then rejected as overlapping. Hooks now never emit, so the group starts at init_as_backup. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The fixtures and captures exercise input ordering and scheduling through the replayer itself, so the hand-built groups and the replay wrapper they needed are removed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Exported records carry pid instead of process_id, and the consensus replayer, its fixtures and the capture tests follow. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The per-process counter in exported records is monotonic, unlike the event time, so it is named m_ts instead of h_ts. The consensus replayer, its fixtures and the capture tests follow. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The step rule now tries bootstrap like any other rule, at a node's first event, and records the bootstrapping node in the rule state, so the driver only repeats the step rule. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Events and groups carry m_ts rather than time, and each field says which trace field it comes from. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Real-node traces, which exercise the cross-process scheduler directly, are to be replayed in CI by a follow-up, so the script and its two workflow steps are removed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Groups were queued per process, with overlapping groups rejected, so that a trace edited into an order one thread could not have produced was refused. A real capture cannot have that order, and the model already rejects a group it is not ready for, so each node's groups now form their own queue. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
0779d6c to
cf29400
Compare
Add --capture-cft-trace to the e2e arguments. When set, each Network lazily starts a recording Fluentd collector when it first configures a node, appends a ccf.cft-only sink to a per-node copy of the observability configuration, and on stop_all_nodes (in a finally) writes <label>_trace/<n>/cft.ndjson with a manifest. The capture is complete only if every configured node, including retired ones, exited cleanly and reported no dropped events for that sink, and every connection reached EOF; otherwise it is inconclusive, which never fails the test. Nodes from released versions are rejected. Enable it for e2e_forwarding_smoke so CI exercises the capture path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Exit only after an idle select that started after stop, so a connection still queued in the listen backlog is accepted and read rather than lost from a capture reported as complete. Spell out the capture path and manifest in the argument help. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Pushed two follow-up commits to reduce CI runner time and speed up
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
gantt
title PR #8732 Elapsed Timeline (T+00:00 = 09:04:43Z, T+16:53 = 09:21:36Z)
dateFormat HH:mm:ss
axisFormat %M:%S
todayMarker off
section ci.yml
Virtual A (queued 11s - ci pool) :done, ci_aq, 00:00:01, 00:00:12
Virtual A (run 12m15s) :ci_ar, 00:00:12, 00:12:27
Virtual C (queued 1m19s - ci-c pool) :done, ci_cq, 00:00:01, 00:01:20
Virtual C (run 10m04s) :ci_cr, 00:01:20, 00:11:24
ACI SNP Genoa (queued 2m28s) :done, ci_sq, 00:00:01, 00:02:29
ACI SNP Genoa (run 9m44s) :ci_sr, 00:02:29, 00:12:13
Virtual B (queued 5m15s - ci-b pool) :crit, done, ci_bq, 00:00:01, 00:05:16
Virtual B (run 10m29s - critical path) :crit, ci_br, 00:05:16, 00:15:45
Replay e2e CFT traces (needs A+B+C, 1m03s) :crit, ci_rep, 00:15:50, 00:16:53
section cross-platform-lts.yml
Configure LTS (5s) :lts_c, 00:00:04, 00:00:09
Build AL3 7.0.28 (queued 1m42s - ci pool) :done, lts_3q, 00:00:09, 00:01:51
Build AL3 7.0.28 (run 6m11s) :lts_3r, 00:01:51, 00:08:02
Build AL4 HEAD (queued 3m48s - ci pool) :done, lts_4q, 00:00:09, 00:03:57
Build AL4 HEAD (run 4m15s) :lts_4r, 00:03:57, 00:08:12
Upgrade AL3->AL4 (queued 14s, needs builds) :done, lts_uq, 00:08:13, 00:08:27
Upgrade AL3->AL4 (run 1m53s) :lts_ur, 00:08:27, 00:10:20
section lean.yml (+ lean-package.yml)
Check common (3m50s) :lp_com, 00:00:05, 00:03:55
Check kv (3m34s) :lp_kv, 00:00:05, 00:03:39
Check consistency (3m35s) :lp_cs, 00:00:04, 00:03:39
Check disaster-recovery (4m38s) :lp_dr, 00:00:05, 00:04:43
Check consensus (7m08s - blocks gatekeeper) :active, lp_con, 00:00:04, 00:07:12
CFT scenario captures (ci-c, 3m11s) :l_cft, 00:00:10, 00:03:21
Replay native CFT (needs cft_traces, 38s) :l_cftr, 00:03:24, 00:04:02
KV trace captures (queued 1m10s - ci-c) :done, l_kvq, 00:00:01, 00:01:11
KV trace captures (run 2m56s) :l_kvr0, 00:01:11, 00:04:07
Replay KV traces (needs kv_traces, 34s) :l_kvr, 00:04:10, 00:04:44
Consistency capture+replay (ci-c, 4m22s) :l_cs, 00:00:11, 00:04:33
Lean models and proofs (needs all, 5s) :active, l_mod, 00:07:15, 00:07:20
section documentation.yml & Copilot
Build documentation (3m30s) :doc_b, 00:00:05, 00:03:35
Deploy (skipped on PR) :milestone, doc_d, 00:03:36, 0s
Copilot PR reviewer (3m37s) :cop_r, 00:00:16, 00:03:53
|
|
cjen1-msft it may make sense to move a bit of B to C if we can, to make up for the extra minute of TV at the end, but it's a very reasonable cost to pay considering the value. |
|
Amaury Chamayou (@achamayou) I've reverted some of the changes you proposed. Then I think we should stack your performance improvement fixes on top in a separate PR, as I think there is some digging we should do to hit a good point on the complexity vs performance curve. |
This is already adding 1 minute to the critical path, I am not happy with adding another minute we don't need. |
There was a problem hiding this comment.
🔵 Needs a closer look
The lenient reducer and scheduler change consensus-conformance coverage, requiring human review of truncation/watermark semantics and the per-node 90% threshold because Lean fixture and real e2e replay validation were unavailable.
Review effort: Balanced
There was a problem hiding this comment.
🔵 Needs a closer look
Lenient replay changes the consensus-conformance boundary, and unavailable Lean/network validation leaves truncation handling and the 90% trace watermark needing human review against representative real-network CI captures.
No open issues 🎉
1 resolved since last review
Review effort: Balanced

The Lean model of the CCF consensus protocol is only checked against
cft_driverscenarios, which run every node in one process on a scripted schedule. This PR checks it against real networks. Every e2e test now records its nodes' trace events, and a new CI job replays theccf.cftevents of each capture against the model, failing if the implementation takes a step the model does not allow. The existing e2e tests, including reconfiguration, elections and partitions, become a conformance check between the model and the implementation on every PR.A capture need not be complete: a test may kill a node before it sends its last events. The replayer therefore gains
--lenient, which stops where it can go no further instead of failing, and reports a watermark: the least fraction of a node's events that it consumed. CI requires a watermark of at least 90% for every capture. A step the model disagrees with still fails the capture outright.The capture is not specific to consensus: it holds the events of every tag, each with its
tag, so other replayers can use it later.Performance optimisations of the replayer are left to a PR stacked on this one.
What is not validated
recovery.py,recovery_snapshot_endorsements.py,identity_recovery_snapshot.py, and parts ofe2e_operations.py,governance.pyandpartitions_test.py; the networks they recover from are validatedNO_TRACE_CAPTURElts_compatibilityNO_TRACE_CAPTUREcft_trace_e2eLABEL perf)logging_cert_blocking_locust,basic_js_locust,basic_blocking_locust,fluentd,logging_jwt_blocking_locust,historical_query_locustci.ymlVirtual jobs: the SNP job, and thecoverage.yml,long-test.ymlandrelease.ymlworkflows (for exampleregression_test_suite)ccf.cfteventsHow it works and how to use it
add_e2e_testpasses--capture-traceto every test, unless it setsNO_TRACE_CAPTUREor is a benchmark.Networkstarts one local FluentdCollectorwhen it first configures a node, and gives each node an extra sink that accepts every tag, keeping any sinks the test configured.<workspace>/<label>_trace/<n>.ndjsonas they arrive, one{tag, ts, pid, m_ts, msg}record per line from every node, wheretsis the event's Fluentd timestamp in nanoseconds. Networks that share a label get separate<n>files, and a test process removes an earlier run's captures the first time it uses a trace folder.stop_all_nodesstops the collector. If the collector failed, it discards the capture and logsDiscarded trace capturewith the reason.Collectorintests/infra/fluentd.pygains an optionalhost, as IPv6-only networks must not have IPv4 addresses in their node configs. Its thread becomes a daemon, so a network that is never stopped cannot keep the test process alive. It replaces bytes that are not UTF-8 instead of failing, as log messages can contain them.consensus-replayignores records whosetagis notccf.cft. With--lenient, a node's groups end before its first event that no rule consumes, and replay ends once no group may run. The output gainswatermark, which is 1 without--lenient.logs-*artifacts. TheReplay e2e consensus tracesjob runs after them, whether or not their tests passed, unless the run was cancelled. It buildsconsensus-replay, or restores it from a cache keyed on the Lean sources, and runstests/cft_trace_validation.pyover their logs. It fails if the model disagrees with a capture, if a watermark is below 90%, or if there is no capture.python3 tests/cft_trace_validation.py <consensus-replay> build/workspace.stop_all_nodesdiff is re-indentation for atry/finally; review it with whitespace hidden.Alternatives